﻿using Abp.Application.Services;
using Abp.AspNetCore.Mvc.Authorization;
using AbpZeroTemplate.Authorization;
using AbpZeroTemplate.Friendships;
using AbpZeroTemplate.Friendships.Dto;
using AbpZeroTemplate.Web.Controllers;
using AbpZeroTemplate.Web.Swagger;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace AbpZeroTemplate.Api.Admin.Controllers
{
    /// <summary>好友
    /// </summary>
    [Area("Admin")]
    [Route("Admin/Friendship/[action]")]
    [ApiName("Admin")]
    [RemoteService]
    [AbpMvcAuthorize]
    public class FriendshipController : AbpZeroTemplateControllerBase
    {
        private readonly IFriendshipAppService _friendshipAppService;
        /// <summary>
        /// </summary>
        public FriendshipController(IFriendshipAppService friendshipAppService)
        {
            _friendshipAppService = friendshipAppService;
        }

        /// <summary>添加好友
        /// </summary>
        [HttpPost]
        public async Task<FriendDto> CreateFriendshipRequest([FromBody]CreateFriendshipRequestInput input)
        {
            return await _friendshipAppService.CreateFriendshipRequest(input);
        }

        /// <summary>根据名称添加好友
        /// </summary>
        [HttpPost]
        public async Task<FriendDto> CreateFriendshipRequestByUserName([FromBody]CreateFriendshipRequestByUserNameInput input)
        {
            return await _friendshipAppService.CreateFriendshipRequestByUserName(input);
        }

        /// <summary>阻止用户
        /// </summary>
        [HttpPost]
        public void BlockUser([FromBody]BlockUserInput input)
        {
            _friendshipAppService.BlockUser(input);
        }

        /// <summary>取消阻止用户
        /// </summary>
        [HttpPost]
        public void UnblockUser([FromBody]UnblockUserInput input)
        {
            _friendshipAppService.UnblockUser(input);
        }

        /// <summary>接受好友请求
        /// </summary>
        [HttpPost]
        public void AcceptFriendshipRequest([FromBody]AcceptFriendshipRequestInput input)
        {
            _friendshipAppService.AcceptFriendshipRequest(input);
        }

    }
}
